package main

import (
	"time"
	"fmt"
)


/**
 * 测试循环
 */
func main() {


	Nine_nineMultiplicationTable()

	testFor2()
	//testFor()

}


//测试For循环
func testFor()  {
	for true {   
		fmt.Printf("这是死循环... %v \n", time.Now())
		fmt.Printf("开始休眠2秒 ....\n")
		time.Sleep(time.Duration(2) * time.Second)
		fmt.Printf("休眠2秒截至.....\n")
	}
}


func testFor2() {   

	var b int = 15
	var a int  

	numbers := []int{1,2,3,4,5,6,7,8,9,10} 


	// 常见循环(与外层的a 不是同一个变量)
	for a :=0 ; a < 10 ; a++ {    
		fmt.Printf("a value is : %d \n", a)
	}

	for a < b {   
		a++
		fmt.Printf("a value is %d \n", a)
	}


	for t,m := range numbers {   
		fmt.Printf("number[%d] is %d \n", t,m)
	}

}

func Nine_nineMultiplicationTable(){

	for i :=1 ; i< 10 ; i++ { 
		fmt.Println() 
		for j :=1; j<10 ; j++ {  
			fmt.Printf("%d x %d = %d \t", i,j,i*j)
		}
		fmt.Println() 
	}
}